package com.authine.cloudpivot.common.extension.customized.kafka;

import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

import java.util.Optional;

/**
 * @author saiwen
 * @date 2021/5/23 17:18
 * description : 网点数据消费
 */
@Component
@Slf4j
public class TestConsumer {

    @KafkaListener(topics = {"test"})
    public void listen(ConsumerRecord<String, String> consumer){
        Optional<String> kafkaMsg = Optional.ofNullable(consumer.value());
        if (kafkaMsg.isPresent()){
            log.info("接收到kafka测试消息：{}", kafkaMsg.get());
        }
    }

}
